<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * Admin/Base Controller
 * 在这里可以定义admin后台需要的通用方法
 */
class ZY_Controller extends CI_Controller {
    private $param;
    public function __construct(){
        parent::__construct();
        $this->get_model();
        $this->is_login();
        //$this->output->enable_profiler(TRUE);
    }

    /**
     * 根据controller加载模型
     */
    function get_model_name(){
        $model_name= strtolower(get_class($this));
        return $model_name;
    }
    protected function get_model(){
        $model_name=$this->get_model_name();
        $this->load->model($model_name."_model",$model_name);
    }
}
class Admin_Controller extends  ZY_Controller{
    /**
     * 判断admin是否登录
     */
    protected function is_login()
    {
        //echo "未登录";
        if($this->session->userdata('user_id')==null){
            redirect(base_url('login'));
        }
    }
    protected function admin_view($view,$data){
        $model_name=$this->get_model_name();
        $this->load->view('admin/include/hearder.php');
        $this->load->view('admin/include/sidebar.php');
        $this->load->view('admin/'.$model_name.'/'.$view, $data);
        $this->load->view('admin/include/footer.php');
    }
}

class Api_Controller extends  ZY_Controller{
    public function __construct(){
        parent::__construct();
    }
}

class ZhiyeAdmin_Controller extends ZY_Controller{
	/**
     * 判断admin是否登录
     */
    protected function is_login()
    {
        //echo "未登录";
        
        if($this->session->userdata('id')==null){
            redirect(base_url('login'));
        }
    }
	protected function zhiyeAdmin_view($view,$data){
        $model_name=$this->get_model_name();
        $this->load->view('admin/include/hearder.php');
        $this->load->view('admin/include/sidebar.php');
        $this->load->view('admin/'.$model_name.'/'.$view, $data);
        $this->load->view('admin/include/footer.php');
		//$this->load->view('zhiye_admin/'.$view, $data);
    }
}